<?php
class ErrorController extends Zend_Controller_Action
{
    public function errorAction()
    {
        $errors = $this->_getParam('error_handler');

        switch ($errors->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
                // 404 error -- controller or action not found
                $this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
                $this->view->title = '404 Not Found';
                $this->view->assign('message',  '該当するページは見つかりませんでした。');
                break;
            default:
                // application error
                // log error
                //require_once 'Zend/Log.php';
                //require_once 'Zend/Log/Writer/Stream.php';
                //$stream = new Zend_Log_Writer_Stream('/path/to/logfile');
                //$logger = new Zend_Log($stream);
                //$exception = $errors->exception;
                //$logger->err($exception->getMessage()
                //              . "\n" .  $exception->getTraceAsString());
                $this->view->title = 'エラー';
                $this->view->assign('message', 'アプリケーションエラーが発生しました。');

                var_dump($errors->exception->getTraceAsString());

                break;
        }

        // Clear previous content
        $this->getResponse()->clearBody();
    }
}